//
//  ViewController.m
//  22--HomeWork QQ音乐界面
//
//  Created by 冀永金 on 16/8/13.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "CustomTableViewCell.h"
#import "HeadView.h"
#import "FirstModel.h"
#import "SecondModel.h"
#import "ListModel.h"
#import "MVModel.h"
#import "MVListModel.h"
#import "LastModel1.h"
#import "JYYNetWorkParser.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableViewOfMV;
@property (nonatomic, strong) HeadView *head;
@property (nonatomic, strong) FirstModel *first;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:nil action:nil];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.22 green:0.75 blue:0.49 alpha:1.00];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
    [self crateTableView];
    [self creatTableViewHead];
    [self handleData];
    //self.navigationController.navigationBar
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)creatTableViewHead {
    self.head = [[HeadView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 300)];
    self.tableViewOfMV.tableHeaderView = self.head;
    //self.head.backgroundColor = [UIColor redColor];
}
- (void)crateTableView {
    self.tableViewOfMV = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    [self.view addSubview:_tableViewOfMV];
    self.tableViewOfMV.delegate = self;
    self.tableViewOfMV.dataSource = self;
    [_tableViewOfMV registerClass:[CustomTableViewCell class] forCellReuseIdentifier:@"pool"];
    _tableViewOfMV.backgroundColor = [UIColor whiteColor];
    _tableViewOfMV.showsVerticalScrollIndicator= NO;
    
}
- (void)handleData {
    [JYYNetWorkParser GETWithURL:@"http://i.y.qq.com/v8/fcg-bin/getmv_by_tag?cmd=mv_shows_new&g_tk=5381&uin=0&format=json&inCharset=utf-8&outCharset=utf-8&notice=0&platform=h5&needNewCode=1&_=1470996835294" par:nil success:^(id responseObject) {
        self.first = [FirstModel modelWithDic:responseObject];
       

        [self.tableViewOfMV reloadData];
        

    } filed:^(NSError *error) {
        
    }];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.first.second.list.list.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
     
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"pool" forIndexPath:indexPath];
   // cell.backgroundColor = [UIColor blueColor];
    MVListModel *model = self.first.second.list.list[ indexPath.section];
    cell.mvlist = model;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 750;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
